package com.tj.jinzao.adapter;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.tj.jinzao.R;
import com.tj.jinzao.activity.QuestionActivity;
import com.tj.jinzao.activity.QuestionDetailActivity;
import com.tj.jinzao.model.QuestionModelBean;
import com.tj.jinzao.utils.ToastUtils;

import java.util.List;

/**
 * Created by LiuYX on 2019/5/31.
 */

public class QuestionListAdapter extends Base_Adapter{
    public QuestionListAdapter(Context context, List list, boolean isFirst) {
        super(context, list, isFirst);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if(convertView==null){
            viewHolder=new ViewHolder();
            convertView= LayoutInflater.from(context).inflate(R.layout.item_question_base,null);
            viewHolder.view_line=findView(convertView,R.id.view_line);
            viewHolder.top=findView(convertView,R.id.top);
            viewHolder.title=findView(convertView,R.id.title);
            convertView.setTag(viewHolder);
        }else {
            viewHolder= (ViewHolder) convertView.getTag();
        }
        QuestionModelBean questionModelBean= (QuestionModelBean) getItem(position);
        if(questionModelBean!=null){
            viewHolder.title.setText(questionModelBean.getSecondDir());
            viewHolder.top.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent to=new Intent();
                    to.putExtra("id",questionModelBean.getId());
                    to.setClass(context, QuestionDetailActivity.class);
                    context.startActivity(to);
                }
            });

        }

        return convertView;
    }
    class ViewHolder{
        View view_line;
        RelativeLayout top;
        TextView title;

    }
}
